﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ScriptCoreLib;
using AvalonTycoonMansion.Shared.Isometric;

namespace AvalonTycoonMansion.Shared
{
	[Script]
	public class KnownTileDescriptions
	{
		public IsometricContainer.TileDescription
			House3,
			House4,

			House5,
			House5a,
			House5b,
			House5c,
			House5x,
			House5z,

			House6,
			House6a,
			House6b,
			House6x,
			House6z,

			House7,
			House7a,
			House7b,
			House7c,
			House7x,
			House7z,

			House10,
			House10a,
			House10b,
			House10x,
			House10z,

			House11,
			House11a,
			House11b,
			House11c,
			House11x,
			House11z,

			House12,
			House12a,
			House12b,
			House12x,
			House12z,

			House13,
			House13a,
			House13b,
			House13x,
			House13z,

			House14,
			House14a,
			House14b,
			House14x,
			House14z,

			House15,
			House15a,
			House15b,
			House15x,
			House15z,

			HeadQuarter,
			RoadXY,
			RoadX,
			RoadX102,
			RoadY,
			RailsX,
			RailsXRoad,
			WildGrass,
			RoughLand,
			Dirt,
			DirtDirtGrass,
			DirtGrassGrass,
			Grass,
			Selection,

			DirtBlock,
			GrassDirtBlock,

			Grass100,
			Grass101,
			Grass102,
			Grass103,
			Grass104,
			Grass105,
			Grass106,
			Grass107,

			Radio1a,
			Radio1b;

		public IsometricContainer.TileDescription[]
			BuildableHouses;

		public KnownTileDescriptions()
		{
			Func<string, int, IsometricContainer.TileDescription> h =
				(SourceName, ImageHeight) => new IsometricContainer.TileDescription
				{
					SourceName = SourceName,
					ImageHeight = ImageHeight,
					Foundation = () => DirtBlock
				};

			Func<string, int, int, IsometricContainer.TileDescription> i =
				(SourceName, ImageWidth, ImageHeight) => new IsometricContainer.TileDescription
				{
					SourceName = SourceName,
					ImageWidth = ImageWidth,
					ImageHeight = ImageHeight,
					Foundation = () => DirtBlock
				};


			Func<string, int, Func<IsometricContainer.TileDescription>, IsometricContainer.TileDescription> a =
				(SourceName, ImageHeight, AnimationNextFrame) => new IsometricContainer.TileDescription
				{
					SourceName = SourceName,
					ImageHeight = ImageHeight,
					AnimationDelay = 5,
					AnimationNextFrame = AnimationNextFrame,
					Foundation = () => DirtBlock
				};

			Func<string, int, int, Func<IsometricContainer.TileDescription>, IsometricContainer.TileDescription> b =
				(SourceName, ImageWidth, ImageHeight, AnimationNextFrame) => new IsometricContainer.TileDescription
				{
					SourceName = SourceName,
					ImageHeight = ImageHeight,
					ImageWidth = ImageWidth,
					AnimationDelay = 5,
					AnimationNextFrame = AnimationNextFrame,
					Foundation = () => DirtBlock
				};


			House3 = new IsometricContainer.TileDescription { SourceName = "h3", ImageHeight = 50, Foundation = () => DirtBlock };
			House4 = new IsometricContainer.TileDescription { SourceName = "h4", ImageHeight = 57, Foundation = () => DirtBlock };
			HeadQuarter = new IsometricContainer.TileDescription { SourceName = "hq", ImageHeight = 107, ImageWidth = 128, SizeX = 2, SizeY = 2, Foundation = () => DirtBlock };

			House5 = a(null, 0, () => House5a);
			House5a = a("h5a", 33, () => House5b);
			House5b = a("h5b", 40, () => House5c);
			House5c = a("h5c", 40, () => House5x);
			House5x = h("h5", 40);
			House5z = a("h5b", 40, () => Dirt);

			House6 = a(null, 0, () => House6a);
			House6a = a("h6a", 43, () => House6b);
			House6b = a("h6b", 43, () => House6x);
			House6x = h("h6x", 43);
			House6z = a("h6b", 43, () => Dirt);

			House7 = a(null, 0, () => House7a);
			House7a = a("h7a", 32, () => House7b);
			House7b = a("h7b", 54, () => House7c);
			House7c = a("h7c", 54, () => House7x);
			House7x = h("h7x", 54);
			House7z = a("h7b", 54, () => Dirt);

			House10 = a(null, 0, () => House10a);
			House10a = a("h10a", 34, () => House10b);
			House10b = a("h10b", 34, () => House10x);
			House10x = h("h10x", 34);
			House10z = a("h10b", 34, () => Dirt);
			House10x.Deconstructor = () => House10z;

			House11 = a(null, 0, () => House11a);
			House11a = a("h11a", 35, () => House11b);
			House11b = a("h11b", 89, () => House11c);
			House11c = a("h11c", 89, () => House11x);
			House11x = h("h11x", 89);
			House11z = a("h11b", 89, () => Dirt);
			House11x.Deconstructor = () => House11z;

			House12 = a(null, 0, () => House12a);
			House12a = b("h12a", 66, 40, () => House12b);
			House12b = b("h12b", 66, 88, () => House12x);
			House12x = i("h12x", 66, 88);
			House12z = b("h12b", 66, 88, () => Dirt);
			House12x.Deconstructor = () => House12z;

			House13 = a(null, 0, () => House13a);
			House13a = b("h13a", 64, 36, () => House13b);
			House13b = b("h13b", 64, 137, () => House13x);
			House13x = i("h13x", 64, 99);
			House13z = b("h13b", 64, 137, () => Dirt);
			House13x.Deconstructor = () => House13z;

			House14 = a(null, 0, () => House14a);
			House14a = b("h14a", 64, 38, () => House14b);
			House14b = b("h14b", 64, 64, () => House14x);
			House14x = i("h14x", 64, 64);
			House14z = b("h14b", 64, 64, () => Dirt);
			House14x.Deconstructor = () => House14z;

			House15 = a(null, 0, () => House15a);
			House15a = b("h15a", 64, 34, () => House15b);
			House15b = b("h15b", 64, 57, () => House15x);
			House15x = i("h15x", 64, 57);
			House15z = b("h15b", 64, 57, () => Dirt);
			House15x.Deconstructor = () => House15z;


			BuildableHouses = new[]
			{
				House5,
				House6,
				House7,
				House10,
				House11,
				House12,
				House13,
				House14,

			};

			RoadXY = "r5";
			RoadX = "r4";
			RoadY = "r1";
			RailsX = "r2";
			RailsXRoad = "r3";
			WildGrass = 2;
			RoughLand = 1;
			Dirt = 4;
			DirtDirtGrass = 5;
			DirtGrassGrass = 6;
			Grass = 0;
			Selection = 3;
			DirtBlock = new IsometricContainer.TileDescription { SourceName = "dirtblock", ImageHeight = 48, Altitude = -16 };
			GrassDirtBlock = new IsometricContainer.TileDescription { SourceName = "grassdirtblock", ImageHeight = 48, Altitude = -16 };
			Grass100 = new IsometricContainer.TileDescription { SourceName = "100", ImageHeight = 39, Altitude = -8 };
			Grass101 = new IsometricContainer.TileDescription { SourceName = "101", ImageHeight = 39, Altitude = -8 };
			Grass102 = new IsometricContainer.TileDescription { SourceName = "102", ImageHeight = 39, Altitude = -8 };
			RoadX102 = new IsometricContainer.TileDescription { SourceName = "r102", ImageHeight = 39, Altitude = -8 };
			Grass103 = new IsometricContainer.TileDescription { SourceName = "103", ImageHeight = 31, Altitude = -8 };
			Grass104 = new IsometricContainer.TileDescription { SourceName = "104", ImageHeight = 23, Altitude = 0 };
			Grass105 = new IsometricContainer.TileDescription { SourceName = "105", ImageHeight = 23, Altitude = 0 };
			Grass106 = new IsometricContainer.TileDescription { SourceName = "106", ImageHeight = 23, Altitude = 0 };
			Grass107 = new IsometricContainer.TileDescription { SourceName = "107", ImageHeight = 31, Altitude = -8 };

			Radio1a = new IsometricContainer.TileDescription { SourceName = "radio1a", ImageHeight = 111, AnimationNextFrame = () => Radio1b, Foundation = () => DirtBlock };
			Radio1b = new IsometricContainer.TileDescription { SourceName = "radio1b", ImageHeight = 111, AnimationNextFrame = () => Radio1a, Foundation = () => DirtBlock };
		}

		public IsometricContainer.TileDescription[] GroupOfHouses
		{
			get
			{
				return new[]
				{
					HeadQuarter,

					House3,
					House4,
					House5x,
					House5a,
					House5b,
					House5c,

					House6x,
					House6a,
					House6b,

					
					House7x,
					House7a,
					House7b,
					House7c,

					House10a,
					House10b,
					House10x,

					House11a,
					House11b,
					House11c,
					House11x,

					House12a,
					House12b,
					House12x,

					House13a,
					House13b,
					House13x,

					House14a,
					House14b,
					House14x,
				};
			}
		}

		public IsometricContainer.TileDescription[] GroupOfTreeLand
		{
			get
			{
				return new[]
				{
					Grass,
					GrassDirtBlock,
					RoughLand,
					WildGrass
				};
			}
		}


	}
}
